package com.qidian.mes.produce.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.Composition;
import com.qidian.mes.produce.service.CompositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 陈俊成
 * @Company ccc
 * @Description
 * @Time 2024/10/21 11:15
 */
@RestController
@RequestMapping("/composition")
@CrossOrigin
public class CompositionController {
    @Autowired
    CompositionService compositionService;

    @GetMapping("/list")
    public MESResult queryList(Integer craftRelId, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return compositionService.queryAllByRelId(craftRelId,page,limit);

    }

    @PostMapping("/add")
    public MESResult addComposition(@RequestBody Composition composition){
        return compositionService.addComposition(composition);
    }

    @PutMapping("/primary")
    public MESResult primaryComposition(@RequestBody Composition composition){
        System.out.println("sdsadsdwqdw+"+composition);
        return compositionService.primaryComposition(composition);
    }

    @GetMapping("/getPrimary")
    public MESResult getPrimary(int compositionRelId){

        return compositionService.getPrimary(compositionRelId);
    }
}
